#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_QtOpenCv.h"
#include <iostream>
#include <thread>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QTimer>
#include <QTcpSocket>
#include <opencv.hpp>
#include <QTimer>
#include <QBuffer>
#include <QMenu>
#include <QInputDialog>
#include <QLineEdit>
#include <QMessageBox>




using namespace cv;

using namespace std;

class QtOpenCv : public QMainWindow
{
    Q_OBJECT

public:
    QtOpenCv(QWidget *parent = nullptr);
    ~QtOpenCv();



    
protected:
    QPointF dragPosition;
    bool isDragging;
    void resizeEvent(QResizeEvent* event) override;
    void mousePressEvent(QMouseEvent* event) override;
    void mouseMoveEvent(QMouseEvent* event) override;
    void mouseReleaseEvent(QMouseEvent* event) override;
protected slots:
    void on_minWidget_clicked();
    void on_restoreWidget_clicked();
    void on_quitApp_clicked();
    void on_actionIP_triggered();
private:
    Ui::QtOpenCvClass ui;
    //打开摄像头
    VideoCapture videoCap;
    CascadeClassifier faceCascade;//人脸检测
    QTcpSocket tcpSocket;
    QTimer checkTimer;
    int sendData;
    //待提取特征向量的Mat图片数据
    Mat faceData;
    //特征向量和描述点
    std::vector<cv::KeyPoint> keypoints;
    cv::Mat descriptors;
    QString IDentityTag;
    QString ipAddresses;

private slots:
    void onReadyRead(QTcpSocket* tcpSocket);
    void timerEvent(QTimerEvent* e);
    void checkFace(Mat videoFrame);
    void timer_connect();
    void start_connect();
    void stop_connect();
};
